class Solution {
public:
    int maximumDetonation(vector<vector<int>>& bombs) {
        bool st[110] = { false };
        queue<vector<int>> q;
        int res = 0;
     
        for (int i = 0; i < bombs.size(); i ++ ) {
            memset(st, false, sizeof st);
            q.push(bombs[i]);
            st[i] = true;
            int cnt = 0;    
            while (q.size()) {
                vector<int> h = q.front(); q.pop();
                cnt ++ ;
                for (int j = 0; j < bombs.size(); j ++ ) {
                    if (st[j]) continue;
                    int dx = h[0] - bombs[j][0], dy = h[1] - bombs[j][1];
                    if ((1ll * dx * dx + 1ll * dy * dy) <= 1ll * h[2] * h[2]) 
                        q.push(bombs[j]), st[j] = true;
                }
            }
            res = max(cnt, res);
        }
        return res;
    }
};
